<?php

class AppController extends Controller {

    var $components = array('Acl', 'Auth', 'Session', 'JqImgcrop');

    function beforeFilter() {
        //Configure AuthComponent
        $this->Auth->authorize = 'actions';
        $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
        $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
        $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'add');
        $this->Auth->allow(array('*'));

//        $user = $this->Session->read('User');
//        if (isset($this->params['admin']) && $this->params['admin'] && is_null($user)) {
//            // set Flash and redirect to login page
//            $this->Session->setFlash('You need to be logged for that action.', 'default', array('class' => 'flash_bad'));
//            $this->redirect(array('controller' => 'users', 'action' => 'login', 'admin' => FALSE));
//        }

        if (isset($this->params['admin']) && $this->params['admin']) {
            $this->layout = "admin";
        }
    }

    function beforeRender() {
        $this->set("controller", $this->name);
    }

}

?>
